package com.swanclouds.redfish.systems.domain.Oem.HuaWei;

import com.fasterxml.jackson.annotation.JsonProperty;
import com.fasterxml.jackson.core.JsonProcessingException;
import com.fasterxml.jackson.databind.ObjectMapper;
import com.swanclouds.model.systems.builder.Oem.HuaWei.HuaWeiCreateVolume;
import com.swanclouds.model.systems.builder.Oem.HuaWei.HuaWeiCreateVolumeBuilder;

import java.util.Map;

/**
 * OEM.Huawei 创城逻辑卷
 *
 * @author 张立强
 */
public class HuaWeiCreateVolumeConcrete implements HuaWeiCreateVolume {

    @JsonProperty("CapacityBytes")
    private Long capacityBytes;

    @JsonProperty("OptimumIOSizeBytes")
    private Integer optimumIOSizeBytes;

    @JsonProperty("Oem")
    private Map<String,Object> oem;

    /**
     * 逻辑盘容量 整数，单位为字节
     *
     * @return capacityBytes
     */
    @Override
    public Long getCapacityBytes() {
        return this.capacityBytes;
    }

    /**
     * 逻辑盘条带大小 整数，单位为字节
     *
     * @return optimumIOSizeBytes
     */
    @Override
    public Integer getOptimumIOSizeBytes() {
        return this.optimumIOSizeBytes;
    }

    /**
     * 自定义属性
     * @return oem
     */
    @Override
    public Map<String, Object> getOem() {
        return this.oem;
    }


    public static HuaWeiCreateVolumeBuilder builder() {
        return new HuaWeiCreateConcreteVolumeBuilder();
    }

    @Override
    public HuaWeiCreateVolumeBuilder toBuilder() {
        return new HuaWeiCreateConcreteVolumeBuilder();
    }

    public static class HuaWeiCreateConcreteVolumeBuilder implements HuaWeiCreateVolumeBuilder {

        HuaWeiCreateVolumeConcrete m;

        HuaWeiCreateConcreteVolumeBuilder() {
            this(new HuaWeiCreateVolumeConcrete());
        }

        HuaWeiCreateConcreteVolumeBuilder(HuaWeiCreateVolumeConcrete m) {
            this.m = m;
        }

        @Override
        public HuaWeiCreateVolumeBuilder CapacityBytes(Long capacityBytes) {
            m.capacityBytes = capacityBytes;
            return this;
        }

        @Override
        public HuaWeiCreateVolumeBuilder OptimumIOSizeBytes(Integer optimumIOSizeBytes) {
            m.optimumIOSizeBytes = optimumIOSizeBytes;
            return this;
        }

        @Override
        public HuaWeiCreateVolumeBuilder Oem(Map<String, Object> oem) {
            m.oem = oem;
            return this;
        }

        /**
         * Creates and return the Model Entity M
         *
         * @return M instance
         */
        @Override
        public HuaWeiCreateVolume build() {
            return m;
        }

        /**
         * Creates a Builder using the param M as the default values
         *
         * @param in The M
         * @return Builder
         */
        @Override
        public HuaWeiCreateVolumeBuilder from(HuaWeiCreateVolume in) {
            m = (HuaWeiCreateVolumeConcrete) in;
            return this;
        }

        @Override
        public String toString() {
            ObjectMapper objectMapper = new ObjectMapper();
            try {
                return objectMapper.writeValueAsString(this);
            } catch (JsonProcessingException e) {
            }
            return "HuaWeiCreateConcreteVolumeBuilder {" +
                    "m=" + m +
                    '}';
        }
    }

    @Override
    public String toString() {
        ObjectMapper objectMapper = new ObjectMapper();
        try {
            return objectMapper.writeValueAsString(this);
        } catch (JsonProcessingException e) {
        }
        return "BMCCreateVolumeConcrete {" +
                "capacityBytes=" + capacityBytes +
                ", optimumIOSizeBytes=" + optimumIOSizeBytes +
                ", oem=" + oem +
                '}';
    }
}
